<template>
	<view>
		<u-sticky>
	<!-- 		<u-button type="success" :plain="true" v-if="faultdata.Status === '未处理' && user.Roles.indexOf('故障审核角色')!=-1"
				@click="Check">设为已处理</u-button>
			<u-button type="warning" :plain="true" v-if="faultdata.Status === '已处理' && user.Roles.indexOf('故障审核角色')!=-1"
				@click="this.modalShow = true">设为未处理</u-button>
				@click="modalShow = true">设为未处理</u-button> -->
				<flowtool :outid="faultdata.Id" flowid="维护工单" :deptid="faultdata.DeptId" :outshowbutton="true" :dataname="faultdata.Name" :formstate="faultdata"></flowtool>
		</u-sticky>
		<u-collapse ref='coll' :value="['1','2']">
			<u-collapse-item name="1" title="工单信息" icon="order">
				<u-cell-group>
					<u-cell title="名称" :use-label-slot="true">
						<span slot="label" class="cell-label">{{faultdata.Name}}</span>
					</u-cell>
					<u-cell title="故障类型" :use-label-slot="true">
						<span slot="label" class="cell-label">{{faultdata.Ftype || " "}}</span>
					</u-cell>
					<u-cell title="地市" :use-label-slot="true" v-if="faultdata.City1">
						<span slot="label" class="cell-label">{{faultdata.City1 || " "}}</span>
					</u-cell>
					<u-cell title="归属区域名称" :use-label-slot="true">
						<span slot="label" class="cell-label">{{faultdata.CityName || " "}}</span>
					</u-cell>
					<u-cell title="安装地址" :use-label-slot="true">
						<span slot="label" class="cell-label">{{faultdata.CustAddr || " "}}</span>
					</u-cell>
					<u-cell title="CM物理地址" :use-label-slot="true">
						<span slot="label" class="cell-label">{{faultdata.CmMac || " "}}</span>
					</u-cell>
					<u-cell title="IP" :use-label-slot="true">
						<span slot="label" class="cell-label">{{faultdata.Ip || " "}}</span> 
						<div slot="right-icon">
							<u-button type="primary" @click="toPing"  v-if="(faultdata.Ip!='' && faultdata.Ftype== 'ping不通')">检查</u-button>
						</div>
					</u-cell>
					<u-cell title="端口" :use-label-slot="true">
						<span slot="label" class="cell-label">{{faultdata.Para || " "}}</span> 
						<div slot="right-icon">
							<u-button type="primary" @click="toPing"  v-if="faultdata.Ftype== '中兴olt端口主干线路断纤' || faultdata.Ftype =='鼎点olt端口主干线路断纤' || 
							faultdata.Ftype =='中兴olt端口局部断纤' || faultdata.Ftype == '鼎点olt端口局部断纤'">检查</u-button>
						</div>
					</u-cell>
					<u-cell title="参数" :use-label-slot="true">
						<span slot="label" class="cell-label">{{faultdata.CountPara || " "}}</span>
					</u-cell>
					<u-cell title="地址" :use-label-slot="true">
						<span slot="label" class="cell-label">{{faultdata.Addr || " "}}</span>
					</u-cell>
					<u-cell title="状态" :use-label-slot="true">
						<span slot="label" class="cell-label">{{faultdata.Status}}</span>
					</u-cell>

					<!-- <u-cell title="经度" :use-label-slot="true">
						<span slot="label" class="cell-label">{{faultdata.Lat || " "}}</span>
					</u-cell>
					<u-cell title="纬度" :use-label-slot="true">
						<span slot="label" class="cell-label">{{faultdata.Lng || " "}}</span>
					</u-cell> -->
					<u-cell title="填写时间" :use-label-slot="true">
						<span slot="label" class="cell-label">{{faultdata.CreateTime}}</span>
					</u-cell>
					<u-cell title="处理时限" :use-label-slot="true">
						<span slot="label" class="cell-label">{{faultdata.TimeLimit || " "}}</span>
					</u-cell>
					<u-cell title="描述" :use-label-slot="true">
						<span slot="label" class="cell-label">{{faultdata.Remark || " "}}</span>
					</u-cell>
					<u-cell title="业务片区名称" :use-label-slot="true">
						<span slot="label" class="cell-label">{{faultdata.AreaName || " "}}</span>
					</u-cell>
					<u-cell title="区域名称" :use-label-slot="true">
						<span slot="label" class="cell-label">{{faultdata.RegionName || " "}}</span>
					</u-cell>
					<u-cell title="大故障名称" :use-label-slot="true">
						<span slot="label" class="cell-label">{{faultdata.BfOrderName || " "}}</span>
					</u-cell>
					<u-cell title="受理日期" :use-label-slot="true">
						<span slot="label" class="cell-label">{{faultdata.OrderDate || " "}}</span>
					</u-cell>
					<u-cell title="完成时限" :use-label-slot="true">
						<span slot="label" class="cell-label">{{faultdata.IntendDate || " "}}</span>
					</u-cell>
					<u-cell title="受理渠道" :use-label-slot="true">
						<span slot="label" class="cell-label">{{faultdata.MType || " "}}</span>
					</u-cell>
					<u-cell title="工单类型" :use-label-slot="true">
						<span slot="label" class="cell-label">{{faultdata.Category || " "}}</span>
					</u-cell>
					<u-cell title="服务类型" :use-label-slot="true">
						<span slot="label" class="cell-label">{{faultdata.AccNbrType || " "}}</span>
					</u-cell>
					<u-cell title="一级需求描述" :use-label-slot="true">
						<span slot="label" class="cell-label">{{faultdata.StypeName || " "}}</span>
					</u-cell>
					<u-cell title="工单等级" :use-label-slot="true">
						<span slot="label" class="cell-label">{{faultdata.Pri || " "}}</span>
					</u-cell>
					<u-cell title="受理内容" :use-label-slot="true">
						<span slot="label" class="cell-label">{{faultdata.Content || " "}}</span>
					</u-cell>
					<u-cell title="预约时间" :use-label-slot="true">
						<span slot="label" class="cell-label">{{faultdata.PromiseTime || " "}}</span>
					</u-cell>
					<u-cell title="督办次数" :use-label-slot="true">
						<span slot="label" class="cell-label">{{faultdata.UrgeCount || " "}}</span>
					</u-cell>
					<u-cell title="主叫号码" :use-label-slot="true">
						<span slot="label" class="cell-label">{{faultdata.CallinCode || " "}}</span>
					</u-cell>
					<u-cell title="预约时间" :use-label-slot="true">
						<span slot="label" class="cell-label">{{faultdata.PromiseTime || " "}}</span>
					</u-cell>
					<u-cell title="质检状态" :use-label-slot="true">
						<span slot="label" class="cell-label">{{faultdata.QcState || " "}}</span>
					</u-cell>
					<u-cell title="工单归组原因" :use-label-slot="true">
						<span slot="label" class="cell-label">{{faultdata.GroupReason || " "}}</span>
					</u-cell>
					<u-cell title="故障原因(故障工单)" :use-label-slot="true">
						<span slot="label" class="cell-label">{{faultdata.LastFaultReason || " "}}</span>
					</u-cell>
					<u-cell title="完成时间" :use-label-slot="true">
						<span slot="label" class="cell-label">{{faultdata.CompleteDate || " "}}</span>
					</u-cell>
					<u-cell title="通话时长" :use-label-slot="true">
						<span slot="label" class="cell-label">{{faultdata.TalkTime || " "}}</span>
					</u-cell>
					<u-cell title="证件类型" :use-label-slot="true">
						<span slot="label" class="cell-label">{{faultdata.CertType || " "}}</span>
					</u-cell>
					<u-cell title="证件号码" :use-label-slot="true">
						<span slot="label" class="cell-label">{{faultdata.CertCode || " "}}</span>
					</u-cell>
					<u-cell title="客户编号" :use-label-slot="true">
						<span slot="label" class="cell-label">{{faultdata.CustNo || " "}}</span>
					</u-cell>
					<u-cell title="客户姓名" :use-label-slot="true">
						<span slot="label" class="cell-label">{{faultdata.CustName || " "}}</span>
					</u-cell>
					<u-cell title="客户类别" :use-label-slot="true">
						<span slot="label" class="cell-label">{{faultdata.CustType || " "}}</span>
					</u-cell>
					<u-cell title="用户状态" :use-label-slot="true">
						<span slot="label" class="cell-label">{{faultdata.CustState || " "}}</span>
					</u-cell>
					<u-cell title="联系人" :use-label-slot="true">
						<span slot="label" class="cell-label">{{faultdata.ConName || " "}}</span>
					</u-cell>
					<u-cell title="联系电话" :use-label-slot="true">
						<span slot="label" class="cell-label">{{faultdata.ConTel || " "}}</span>
					</u-cell>
					<u-cell title="联系手机" :use-label-slot="true">
						<span slot="label" class="cell-label">{{faultdata.ConMobile || " "}}</span>
					</u-cell>
					<u-cell title="联系地址" :use-label-slot="true">
						<span slot="label" class="cell-label">{{faultdata.ConAddr || " "}}</span>
					</u-cell>
					<u-cell title="小区编号" :use-label-slot="true">
						<span slot="label" class="cell-label">{{faultdata.UnitCode || " "}}</span>
					</u-cell>
					<u-cell title="小区名称" :use-label-slot="true">
						<span slot="label" class="cell-label">{{faultdata.UnitName || " "}}</span>
					</u-cell>
					<u-cell title="用户编号" :use-label-slot="true">
						<span slot="label" class="cell-label">{{faultdata.SmNo || " "}}</span>
					</u-cell>
					<u-cell title="用户状态" :use-label-slot="true">
						<span slot="label" class="cell-label">{{faultdata.SmState || " "}}</span>
					</u-cell>
					<u-cell title="机顶盒号" :use-label-slot="true">
						<span slot="label" class="cell-label">{{faultdata.StbNo || " "}}</span>
					</u-cell>
					<u-cell title="机顶盒品牌" :use-label-slot="true">
						<span slot="label" class="cell-label">{{faultdata.StbCompany || " "}}</span>
					</u-cell>
					<u-cell title="客户等级" :use-label-slot="true">
						<span slot="label" class="cell-label">{{faultdata.CustPri || " "}}</span>
					</u-cell>
					<u-cell title="希望反馈时间" :use-label-slot="true">
						<span slot="label" class="cell-label">{{faultdata.FeedbackTime || " "}}</span>
					</u-cell>
					<u-cell title="智能卡类型" :use-label-slot="true">
						<span slot="label" class="cell-label">{{faultdata.TerminatorType || " "}}</span>
					</u-cell>
					<u-cell title="光机" :use-label-slot="true">
						<span slot="label" class="cell-label">{{faultdata.BranchFont || " "}}</span>
					</u-cell>
					<u-cell title="分前端" :use-label-slot="true">
						<span slot="label" class="cell-label">{{faultdata.OpticMachine || " "}}</span>
					</u-cell>
					<u-cell title="邮政编码" :use-label-slot="true">
						<span slot="label" class="cell-label">{{faultdata.Zip || " "}}</span>
					</u-cell>
					<u-cell title="Email" :use-label-slot="true">
						<span slot="label" class="cell-label">{{faultdata.Email || " "}}</span>
					</u-cell>
					<u-cell title="转生新单原单号" :use-label-slot="true">
						<span slot="label" class="cell-label">{{faultdata.ParOrderId || " "}}</span>
					</u-cell>
					<u-cell title="打印人" :use-label-slot="true">
						<span slot="label" class="cell-label">{{faultdata.PrintStaff || " "}}</span>
					</u-cell>
					<u-cell title="从呼叫中心流出时间" :use-label-slot="true">
						<span slot="label" class="cell-label">{{faultdata.SendDate || " "}}</span>
					</u-cell>
					<u-cell title="最后一次处理环节时间" :use-label-slot="true">
						<span slot="label" class="cell-label">{{faultdata.FinalDealDate || " "}}</span>
					</u-cell>
					<u-cell title="最后一次处理环节填写的结果" :use-label-slot="true">
						<span slot="label" class="cell-label">{{faultdata.FinalContent || " "}}</span>
					</u-cell>
					<u-cell title="处理结果" :use-label-slot="true">
						<span slot="label" class="cell-label">{{faultdata.FinalCode || " "}}</span>
					</u-cell>
					<u-cell title="最后一次回访填写的结果" :use-label-slot="true">
						<span slot="label" class="cell-label">{{faultdata.CallbackContent || " "}}</span>
					</u-cell>
					<u-cell title="下次回访时间" :use-label-slot="true">
						<span slot="label" class="cell-label">{{faultdata.NextCallback || " "}}</span>
					</u-cell>
					<u-cell title="回访次数" :use-label-slot="true">
						<span slot="label" class="cell-label">{{faultdata.CallbackCount || " "}}</span>
					</u-cell>
					<u-cell title="回访满意度编码" :use-label-slot="true">
						<span slot="label" class="cell-label">{{faultdata.SatisfyCode || " "}}</span>
					</u-cell>
					<u-cell title="受理编号" :use-label-slot="true">
						<span slot="label" class="cell-label">{{faultdata.BusiCustName || " "}}</span>
					</u-cell>
					<u-cell title="模拟编号" :use-label-slot="true">
						<span slot="label" class="cell-label">{{faultdata.SimulateId || " "}}</span>
					</u-cell>
					<u-cell title="城区编码" :use-label-slot="true">
						<span slot="label" class="cell-label">{{faultdata.CountyZone || " "}}</span>
					</u-cell>
					<u-cell title="区域名称" :use-label-slot="true">
						<span slot="label" class="cell-label">{{faultdata.DistrictName || " "}}</span>
					</u-cell>
					<u-cell title="客户优惠类型" :use-label-slot="true">
						<span slot="label" class="cell-label">{{faultdata.FavourType || " "}}</span>
					</u-cell>
					<u-cell title="客户种类" :use-label-slot="true">
						<span slot="label" class="cell-label">{{faultdata.CustColony || " "}}</span>
					</u-cell>
					<u-cell title="性别" :use-label-slot="true">
						<span slot="label" class="cell-label">{{faultdata.Sex || " "}}</span>
					</u-cell>
					<u-cell title="集团联系电话" :use-label-slot="true">
						<span slot="label" class="cell-label">{{faultdata.GroupTel || " "}}</span>
					</u-cell>
					<u-cell title="集团联系人" :use-label-slot="true">
						<span slot="label" class="cell-label">{{faultdata.GroupLinkMan || " "}}</span>
					</u-cell>
					<u-cell title="协议编号" :use-label-slot="true">
						<span slot="label" class="cell-label">{{faultdata.ContractCode || " "}}</span>
					</u-cell>
					<u-cell title="备注电话" :use-label-slot="true">
						<span slot="label" class="cell-label">{{faultdata.RemarkTel || " "}}</span>
					</u-cell>
					<u-cell title="网络类别" :use-label-slot="true">
						<span slot="label" class="cell-label">{{faultdata.NetType || " "}}</span>
					</u-cell>
					<u-cell title="客户备注信息" :use-label-slot="true">
						<span slot="label" class="cell-label">{{faultdata.Remark1 || " "}}</span>
					</u-cell>
					<u-cell title="是否到期即停" :use-label-slot="true">
						<span slot="label" class="cell-label">{{faultdata.IsBlack || " "}}</span>
					</u-cell>
					<u-cell title="智能卡号" :use-label-slot="true">
						<span slot="label" class="cell-label">{{faultdata.EquipNo || " "}}</span>
					</u-cell>
					<u-cell title="宽带账号" :use-label-slot="true">
						<span slot="label" class="cell-label">{{faultdata.CmLoginName || " "}}</span>
					</u-cell>
					<u-cell title="VIP客户类型" :use-label-slot="true">
						<span slot="label" class="cell-label">{{faultdata.VIPCustType || " "}}</span>
					</u-cell>
					<u-cell title="旧机顶盒号" :use-label-slot="true">
						<span slot="label" class="cell-label">{{faultdata.OldStbNo || " "}}</span>
					</u-cell>
					<u-cell title="原地址" :use-label-slot="true">
						<span slot="label" class="cell-label">{{faultdata.OldAddress || " "}}</span>
					</u-cell>
					<u-cell title="新地址" :use-label-slot="true">
						<span slot="label" class="cell-label">{{faultdata.NewAddress || " "}}</span>
					</u-cell>
					<u-cell title="单据类型" :use-label-slot="true">
						<span slot="label" class="cell-label">{{faultdata.PrintTypeName || " "}}</span>
					</u-cell>
					<u-cell title="终端数" :use-label-slot="true">
						<span slot="label" class="cell-label">{{faultdata.TotalUser || " "}}</span>
					</u-cell>
					<u-cell title="单据标题" :use-label-slot="true">
						<span slot="label" class="cell-label">{{faultdata.Title || " "}}</span>
					</u-cell>
					<u-cell title="是否合约机" :use-label-slot="true">
						<span slot="label" class="cell-label">{{faultdata.IsContract || " "}}</span>
					</u-cell>
					<u-cell title="终端类型" :use-label-slot="true">
						<span slot="label" class="cell-label">{{faultdata.UserType || " "}}</span>
					</u-cell>
					<u-cell title="意向订单号" :use-label-slot="true">
						<span slot="label" class="cell-label">{{faultdata.Blank0 || " "}}</span>
					</u-cell>
					<u-cell title="网格编码" :use-label-slot="true">
						<span slot="label" class="cell-label">{{faultdata.Blank3 || " "}}</span>
					</u-cell>
					<u-cell title="网格名称" :use-label-slot="true">
						<span slot="label" class="cell-label">{{faultdata.Blank4 || " "}}</span>
					</u-cell>
					<u-cell title="维护人员" :use-label-slot="true">
						<span slot="label" class="cell-label">{{faultdata.Blank5 || " "}}</span>
					</u-cell>
					<u-cell title="派单时间" :use-label-slot="true">
						<span slot="label" class="cell-label">{{faultdata.CreateTime1 || " "}}</span>
					</u-cell>
				</u-cell-group>
			</u-collapse-item>
			<u-collapse-item name="2" title="故障照片" icon="https://project.gxrunxiang.com/cdn/image.png">
				<u-album :urls="imagesurls1"></u-album>
			</u-collapse-item>
			<u-collapse-item name="2" title="其他" icon="https://project.gxrunxiang.com/cdn/image.png">
				<u-album :urls="imagesurls2"></u-album>
			</u-collapse-item>
		<u-button type="error" :plain="true" v-if="user.Roles.indexOf('故障填报角色')!=-1 || user.Roles.indexOf('故障审核角色')!=-1"
			@click="delmodalShow = true">删除</u-button>
		</u-collapse>
		<u-toast ref="uToast"></u-toast>
		<u-modal :show="delmodalShow" title="提示" content='确认删除?' @confirm="del" :showCancelButton="true"
			confirmText="是" cancelText="否" @cancel="delmodalShow = false" :closeOnClickOverlay="true"
			@close="delmodalShow = false"></u-modal>
			
		<u-modal :show="modalShow" title="提示" content='处理时间会重置，确定设为未处理吗?' @confirm="uncheck" :showCancelButton="true"
			confirmText="是" cancelText="否" @cancel="modalShow = false" :closeOnClickOverlay="true"
			@close="modalShow = false"></u-modal>
	</view>
</template>
<script>
	import {
		baseUrl
	} from '@/common/config.js'
	import flowtool from "../c_flowtool.vue"
	import {
		mapGetters
	} from 'vuex'
	import {
		getfaultlist,
		getfilebyoutid,
		checkfault,
		uncheckfault,
		delfault,
		CheckAll
		// pingfault,
		// checkZTEpoint,
		// CheckToppoint
	} from '@/common/api.js'
	export default {
		components: {
		  flowtool
		},
		data() {
			return {
				faultid: "",
				faultdata: [],
				imagesurls1: [],
				imagesurls2: [],
				modalShow: false,
				delmodalShow: false,
				user: {}
			}
		},
		onLoad(option) {
			this.user = JSON.parse(uni.getStorageSync("$userinfo"))
			this.faultid = option.id
			this.getlist(this.faultid)
		},
		methods: {
			async getlist(id) {
				let para = {
					Parameters: [],
				}
				para.Parameters.push({
					FieldName: "Id",
					ConditionalType: "Equal",
					FieldValue: id
				})
				await getfaultlist(para).then(res => {
					this.faultdata = res.data[0]
				})
				this.imagesurls1 = []
				this.imagesurls2 = []
				getfilebyoutid(this.faultid).then(res => {
					for (var i = 0; i < res.length; i++) {
						if (res[i].MyType == '故障照片') {
							this.imagesurls1.push(`${baseUrl}/SysFile/download?id=${res[i].Id}`)
						}
						if (res[i].MyType == '其他') {
							this.imagesurls2.push(`${baseUrl}/SysFile/download?id=${res[i].Id}`)
						}
					}
					setTimeout(() => {
							this.$refs.coll.init()
						},
						1000)
				})
			},
			Check() {
				let ids = []
				ids.push(this.faultid)
				checkfault(ids).then((res) => {
					if (res == true) {
						uni.navigateBack()
					}
				})
			},
			uncheck() {
				let ids = []
				ids.push(this.faultid)
				uncheckfault(ids).then((res) => {
					if (res == true)
						uni.navigateBack()
				})
			},
			del(){
				let ids = []
				ids.push(this.faultid)
				delfault(ids).then((res) => {
					if (res == true)
						uni.navigateBack()
				})
				},
			toPing(){
				CheckAll(this.faultdata).then((res) => {
					if(res.code == -1){
						this.$refs.uToast.show({
							message: res.message,
							type: 'error',
							position: 'top',
							duration: 4000
						})
						
					}
					else if(res.code == 0){
						this.$refs.uToast.show({
							message: res.message,
							type: 'success',
							position: 'top',
							duration: 4000
						})
					}
					return 
				})		
				}
		}
	}
</script>
<style>
	.cell-label {
		margin-top: 10px;
		font-size: 14px;
		color: #909193;
	}
</style>